package com.tjc.eventbus;

/**
 * @Author: tjc
 * @description
 * @Date Created in 22:46 2022-01-12
 */
public class Test {
    volatile int i;

    public Test(int i) {
        this.i = i;
        new Thread(new Task()).start();
    }

    private class Task implements Runnable {

        @Override
        public void run() {
            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(i);
            }
        }
    }

    public static void main(String[] args) throws NoSuchMethodException, InterruptedException {
        Test test = new Test(1);

        while (true) {
            Thread.sleep(1000);
            test.i++;
        }
    }
}